package com.action;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.AdminBean;
import com.dao.AdminDao;
import com.exception.AdminException;
import com.exception.DBException;

public class LoginAction
{

	public void confirmAdmin(HttpServletRequest request,
			HttpServletResponse response,AdminBean admin) throws AdminException, DBException
	{
		String root = request.getContextPath() + "/";
		AdminDao login = new AdminDao();

		if (login.administratorLogin(admin))
		{
			request.getSession().setAttribute("admin", admin);
			try
			{
				response.sendRedirect(root + "main.jsp");
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
		else
		{
			try
			{
				response.sendRedirect(root + "loginError.jsp");
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
	}

}
